package jmine.tec.hydra.script.impl;

import jmine.tec.hydra.api.HydraMessage;
import jmine.tec.hydra.script.DispatchScriptContext;
import jmine.tec.script.persistent.context.impl.AbstractScriptExecutionContext;

/**
 * Implementação de {@link DispatchScriptContext}
 * 
 * @author jrenaut
 */
public class DispatchScriptContextImpl extends AbstractScriptExecutionContext<DispatchResult> implements DispatchScriptContext {

    private static final String MESSAGE = "message";

    private static final String RESULT = "result";

    private DispatchResult result = new DispatchResult();

    /**
     * {@inheritDoc}
     */
    public DispatchScriptContext prepare(HydraMessage message) {
        this.getParameters().putParameter(MESSAGE, message, HydraMessage.class);
        this.getParameters().putParameter(RESULT, this.result, DispatchResult.class);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    public String getTracer() {
        return this.result.getAllLogs();
    }

    /**
     * {@inheritDoc}
     */
    public DispatchResult getResult() {
        return this.result;
    }

}
